/**
 * [228] 汇总区间
 *
 * @format
 * @lc app=leetcode.cn id=228 lang=javascript
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @return {string[]}
 */
var summaryRanges = function (nums) {
    let start = nums[0]
    const result = []
    for (let i = 0; i < nums.length; i++) {
        if (nums[i] + 1 == nums[i + 1]) continue
        else if (start == nums[i]) result.push("" + start), (start = nums[i + 1])
        else result.push(`${start}->${nums[i]}`), (start = nums[i + 1])
    }
    return result
}
// @lc code=end
